home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / c_news / 05 / listings / f_functi.asm < prev    next >
Assembly Source File  |  1988-03-04  |  4KB  |  138 lines

  1.     PAGE    55,132
  2.     NAME    f_functi
  3.     TITLE    FOSSIL Interface Routines for Microsoft C and Turbo C
  4.     SUBTTL    Copyright 1988 Marshall Presnell; All Rights Reserved
  5.  
  6. ;************************************************************************; 
  7. ;*                                    *; 
  8. ;*        Assembled with Microsoft Macro Assembler version 5        *; 
  9. ;*           using MIXED.MAC mixed language macro package.        *; 
  10. ;*                                    *; 
  11. ;************************************************************************; 
  12.  
  13. ; NOTE: These functions act... well.... strange. They DO load the proper
  14. ;    registers and execute the INT 14 call, but somehow I haven't 
  15. ;    figured out why the code doesn't hook the timer tick.....
  16. ;
  17. ;    Will examine it closer and make a later version available when I
  18. ;    figure the problem out. Or if YOU figure it out, send me a copy
  19. ;    (and an explanation!)
  20.  
  21. ;========================================================================; 
  22. ;=----------------------------------------------------------------------=; 
  23. ;=-                                                                    -=; 
  24. ;=-          THIS MODULE HAS BEEN RELEASED FOR USE IN C NEWS           -=; 
  25. ;=-                                             -=; 
  26. ;=-        ANY QUESTIONS, COMMENTS, OR PROBLEMS SHOULD BE ADDRESSED TO    -=; 
  27. ;=-                                             -=; 
  28. ;=-                 MARSHALL PRESNELL                   -=; 
  29. ;=-                 13652 LYNN STREET                   -=; 
  30. ;=-               WOODBRIDGE, VA  22191               -=; 
  31. ;=-                                             -=; 
  32. ;=-            FIDONET ADDRESS 109/639.106               -=; 
  33. ;=-                                       -=; 
  34. ;=----------------------------------------------------------------------=; 
  35. ;========================================================================; 
  36.  
  37.     .8086
  38.     INCLUDE    MIXED.MAC
  39.     SETMODEL
  40.  
  41.     .CODE
  42.  
  43. ;==========================================================================;
  44. ;                                       ;
  45. ;        SYSTEM EQUATES FOR FOSSIL VERSION 5 INTERFACE           ;
  46. ;                                       ;
  47. ;==========================================================================;
  48.  
  49. SETBAUD        EQU    00H
  50. TXCHAR        EQU    01H
  51. RXCHAR        EQU    02H
  52. STATUS        EQU    03H
  53. INIT        EQU    04H
  54. DEINIT        EQU    05H
  55. DTR        EQU    06H
  56. TTICK        EQU    07H
  57. OUTFLUSH    EQU    08H
  58. OUTPURGE    EQU    09H
  59. INPURGE        EQU    0AH
  60. TXNOWAIT    EQU    0BH
  61. PEEK        EQU    0CH
  62. KEYREADNOWAIT    EQU    0DH
  63. KEYREAD        EQU    0EH
  64. FLOWCONTROL    EQU    0FH
  65. CONTROL_C_CHECK    EQU    10H
  66. SETCURS        EQU    11H
  67. GETCURS        EQU    12H
  68. WRANSI        EQU    13H
  69. WATCHDOG    EQU    14H
  70. WRBIOS        EQU    15H
  71. TTICK_FUNCTION    EQU    16H
  72. REBOOT        EQU    17H
  73. READBLOCK    EQU    18H
  74. WRITEBLOCK    EQU    19H
  75. BREAK        EQU    1AH
  76. DATASTRUCTURE    EQU    1BH
  77. INSTALLAPI    EQU    7EH
  78. REMOVEAPI    EQU    7FH
  79.  
  80. ;===========================================================================
  81. ;
  82. ;    unsigned int f_insertfunc(void (far * func)());
  83. ;
  84.  
  85. HPROC    <f_insertfunc>,<USES DX>,FUNCTION:PTR
  86.  
  87.     PUSH    ES            ;Save ES 
  88.     PUSH    DS            ;  ... and DS
  89.  
  90.     MOV    AX, CS            ;Load ES and DS with
  91.     MOV    ES, AX            ;the current code segment.
  92.     MOV    DS, AX            ;Assuming small model
  93.  
  94.     MOV    AL, 1            ;Load AL with Insert sub-function code
  95.     MOV    AH, TTICK_FUNCTION    ;Load AH with main function code
  96.     PLES    DX, FUNCTION        ;Load ES:DX with far pointer on stack
  97.     PUSH    ES            ;Make it also valid through
  98.     POP    DS            ; DS:DX
  99.     INT    14H            ;Call FOSSIL
  100.  
  101.     POP    DS            ;Restore DS and 
  102.     POP    ES            ;ES to their entry values
  103.  
  104.     HRET                ;Return AX to caller
  105.  
  106. HENDP    f_insertfunc
  107.  
  108. ;---------------------------------------------------------------------------
  109. ;
  110. ;    unsigned int f_removefunc(void (far * func)());
  111. ;
  112.  
  113. HPROC    <f_removefunc>,<USES DX>,FUNCTION:PTR
  114.  
  115.     PUSH    ES            ;Save ES 
  116.     PUSH    DS            ;  ... and DS
  117.  
  118.     MOV    AX, CS            ;Load ES and DS with
  119.     MOV    ES, AX            ;the current code segment.
  120.     MOV    DS, AX            ;Assuming small model
  121.  
  122.     MOV    AL, 0            ;Load AL with Remove sub-function code
  123.     MOV    AH, TTICK_FUNCTION    ;Load AH with main function code
  124.     PLES    DX, FUNCTION        ;Load ES:DX with far pointer on stack
  125.     PUSH    ES            ;Make it also valid through
  126.     POP    DS            ; DS:DX
  127.     INT    14H            ;Call FOSSIL
  128.  
  129.     POP    DS            ;Restore DS and 
  130.     POP    ES            ;ES to their entry values
  131.  
  132.     HRET                ;Return AX to caller
  133.  
  134. HENDP    f_removefunc
  135.  
  136.     END
  137.  
  138.